home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
pcxbgi2.exe
/
lha
/
TPDEMO2.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1991-03-02
|
4KB
|
147 lines
{**************************************************************************
* Program: TPDemo2.pas *
* Author: Marty Balash *
* Date: 03/02/91 *
* Remarks: How to display multiple .MJB images using Turbo Pascal *
* *
* NOTE: See TPDemo1.pas for more comments *
* DEMO.PCX was used to create the images *
**************************************************************************}
program tpdemo;
uses crt,graph;
const basefn1 = 'BGI1';
const basefn2 = 'BGI2';
const basefn3 = 'BGI3';
const basefn4 = 'BGI4';
const basefn5 = 'BGI5';
const basefn6 = 'BGI6';
const basefn7 = 'BGI7';
const basefn8 = 'BGI8';
const imsize = 7702; { In PCX2BGI.EXE, all images were framed (as partial
screens) and saved to same size files }
type imagehdr = record
id : array [1..8] of char;
size : word;
palette : palettetype;
end;
type imagedata = { All images are same size, so only one type is needed }
array[1..imsize] of byte;
var
hdr:imagehdr; { only need one header - all images are from same screen }
dat: array [1..8] of imagedata; { array of 8 image buffers }
hdrhandle:file of imagehdr;
dathandle:file of imagedata;
datfn: array [1..8] of string[12];
i,a:integer; { work vars }
pageflag:integer; { needed by pageflip procedure }
procedure openegascreen; { Open 640x350 16-color EGA screen }
var
driver,mode,result:integer;
begin
driver := ega;
mode := egahi;
initgraph(driver,mode,'');
result := graphresult;
if result <> grok then
begin
write('ERROR: ',grapherrormsg(result));
exit;
end;
end;
procedure readimage;
var
hdrname:string[7];
hdrfn:string[12];
begin
hdrfn:=basefn1+'.HDR';
datfn[1]:=basefn1+'.DAT';
datfn[2]:=basefn2+'.DAT';
datfn[3]:=basefn3+'.DAT';
datfn[4]:=basefn4+'.DAT';
datfn[5]:=basefn5+'.DAT';
datfn[6]:=basefn6+'.DAT';
datfn[7]:=basefn7+'.DAT';
datfn[8]:=basefn8+'.DAT';
assign(hdrhandle,hdrfn);
{$I-}
reset(hdrhandle);
{$I+}
if ioresult <> 0 then
exit;
read(hdrhandle,hdr);
close(hdrhandle);
hdrname:=hdr.id[1]+hdr.id[2]+hdr.id[3]+hdr.id[4]+hdr.id[5]+hdr.id[6]+hdr.id[7];
if hdrname <> 'PCX2BGI' then
exit;
setallpalette(hdr.palette);
for i:=1 to 8 do { read in 8 images }
begin
assign(dathandle,datfn[i]);
{$I-}
reset(dathandle);
{$I+}
if ioresult <> 0 then
exit;
read(dathandle,dat[i]);
close(dathandle);
end
end;
procedure pageflip; { alternate pages for smoother animation }
begin
if pageflag=1 then
begin
pageflag:=0;
setactivepage(1);
setvisualpage(0);
end
else
begin
pageflag:=1;
setactivepage(0);
setvisualpage(1);
end;
end;
begin
openegascreen;
readimage;
a:=10;
pageflag:=0;
repeat
if a>220 then
begin
for i:= 8 downto 1 do
begin
putimage(a,125,dat[i],NormalPut);
delay(100);
pageflip;
end;
delay(1000);
end
else
begin
for i:= 8 downto 1 do
begin
putimage(a,125,dat[i],NormalPut);
pageflip;
end;
for i:=1 to 8 do
begin
putimage(a,125,dat[i],NormalPut);
pageflip;
end;
a:=a+10;
end;
until keypressed;
closegraph;
writeln('Created with PCX2BGI.EXE by Marty Balash');
end.